<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 7/10/14
 * Time: 1:07 PM
 */

class Category_Widget_Filter_Controller extends Base_Controller {

    public $restful = true;

    public function __construct()
    {
        parent::__construct();
        //--Your Code --//
    }


    public function get_category($category){

    	$data['mode'] = "CAT";
     	$cID = $category;
        $exp = explode('-',Categories::find($cID)->lineage);
        $data['exp'] = $exp;
      
    	$cID = $category;
    	//dd($cID);
    	$deep = Categories::find($cID)->deep;
		$lineage = Categories::find($cID)->lineage;
		
		for($i = 0; $i <= $deep;$i++){
			$exp = explode('-', $lineage);
		}
		
		$ctr = count($exp);
		$child=array();
		
		for($i=0; $i<$ctr; ++$i){
			$child[$i]=Hierarchy::get_children('categories',intval($exp[$i]),15);
		}
		
		$data['child']=$child;
		
    	
        return View::make('Category::widget.filter',$data);
    }
    
    public function get_cat(){
    
    	$data['mode'] = "LOC";
    	$data['parent'] = Categories::where('parent_id','=',0)->get(array('id','name','slug')); 
    	//Categories::parent(0)->get(array('id','name','slug'));
    	
    	return View::make('Category::widget.filter',$data);
    }
}